package com.yazi.mxz.common;

import java.io.IOException;
import java.util.Properties;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


public class Config {
	private static Logger log = LoggerFactory.getLogger(Config.class);
	private static Properties preperties;
	private static Config config;
	static {
		reset();
	}
	
	public static void reset() {
		preperties = new Properties();
		try {
			preperties.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("system.properties"));
		} catch (IOException e) {
			log.error("找不到配置文件[classpath:system.properties]");
		}
	}
	
	public static Config getInstance() {
		if (null == config) {
			config = new Config();
		}
		return config;
	}
	public String getEncoding() {
		return getProperty("st.com.encoding");
	}
	public String getName() {
		return getProperty("st.com.name");
	}
	public String getHome() {
		return getProperty("st.com.home");
	}
	public String getUploadPath() {
		return getProperty("st.com.upload_path");
	}
	public String getDomain() {
		return getProperty("st.domain");
	}
	public String getResDomain() {
		return getProperty("st.domain.res");
	}
	public String getAttaDomain() {
		return getProperty("st.domain.atta");
	}
	public String getArticleDomain() {
		return getProperty("st.domain.article");
	}
	
	protected String getProperty(String key) {
		return String.valueOf(preperties.get(key));
	}
	
}
